Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use google translate #189

Merged
merged 18 commits into from
Aug 8, 2024
Merged

Use google translate #189

merged 18 commits into from
Aug 8, 2024

Conversation

NancyAanchal
Copy link
Contributor

added a getGTranslate lib
Udated the useDictionary to use getGTranslate for maithili and for newari backup.

challenges:
Error: Requests from referer http://localhost:5173/ are blocked.

can't test it because of this error.

Tried setting up a proxy server (have created a file called proxy.js) but am not sure about it and don't know how to use it.

Copy link

cloudflare-workers-and-pages bot commented Aug 5, 2024

Deploying nepalingo with  Cloudflare Pages  Cloudflare Pages

Latest commit: 5f44292
Status: ✅  Deploy successful!
Preview URL: https://53208a13.nepalingo.pages.dev
Branch Preview URL: https://use-google-translate.nepalingo.pages.dev

View logs

Copy link
Member

@binamkayastha binamkayastha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments, feel free to merge the PR in after you address them

"lottie-react": "^2.4.0",
"node-fetch": "^3.3.2",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need these packages?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove them and re-generate the pnpm lock file?

if (newariResult.meanings.length === 0) {
console.log("Used Google Translate for newari");
return await getGTranslate("newari", word);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice and simple! This is some nice DRY code!

case "Tajpuriya":
return await getTajpuriyaWord(word);
case "Maithili":
return await getGTranslate("maithili", word);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ooo I like that

}> => {
const targetLanguage = languageCodes[language];
if (!targetLanguage) {
throw new Error(`Language code for ${language} not found`);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
throw new Error(`Language code for ${language} not found`);
throw new Error(`Google translate language code for ${language} not found`);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change will make it more clear why the error is occurring and hints at what file to look at.

@@ -0,0 +1,45 @@
const GOOGLE_TRANSLATE_API_KEY = "AIzaSyCi239eredIAEEJkI8xzvGwW1GPS7B1vxQ";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move this into the .env file

@NancyAanchal NancyAanchal merged commit 566c729 into main Aug 8, 2024
2 checks passed
@NancyAanchal NancyAanchal deleted the use-google-translate branch August 8, 2024 10:40
@binamkayastha
Copy link
Member

Nice thanks for testing and catching that env var error before merging!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants